//数据请求配置
const api = require('../config/config').api;
const networkModel = require('../libs/networkModel');  //引入fetch发送的网络请求模型

//引入具体数据的操作服务


//index model class
class IndexModel extends networkModel {
  //获取首页
  getIndexPageData () {
    return {
      msg: 'hello world!'
    }
  }

  //获取小米数据
  getXiaomiDatas (options){
      //继承封装的fetch请求类
    const swiper = options.swiper || true,
          phone = options.phone || true,
          field = options.field || true;
    const url = `${api.getXiaomiDatas}?swiper=${swiper}&phone=${phone}&field=${field}`;

   const data = this.get(url, {
      success(res) {
        return res;
      },
      error(err){
        throw new Error('error: ' + err);
      }
    });

    return data;
  }
}

module.exports = new IndexModel(); //实例化
